home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS14.ADF / DosHelper / DOSHelper.c < prev    next >
C/C++ Source or Header  |  1989-01-28  |  25KB  |  801 lines

  1. /*************************************************************************
  2. *                                                                        *
  3. *                                                                        *
  4. *                       DOSHelper Version 1.60                           *
  5. *                         by  John Youells                               *
  6. *                        &  Wayne Westfield                              *
  7. *                     ⌐ John Youells & LifeStream                        *
  8. *                                                                        *
  9. *                                                                        *
  10. *                                                                        *
  11. *                                                                        *
  12. *    This program is being distributed as "shareware".  If you like  it, *
  13. *             and use it  please send $10.00 to:                         *
  14. *                       John Youells                                     *
  15. *                       94 Second Ave.                                   *
  16. *                       Kingston, PA 18704                               *
  17. *                                                                        *
  18. *                                                                        *
  19. *    Feel free to distribute this program to other Amiga users and       *
  20. *    modify it to suit your needs as long as the original credits        *
  21. *    remain intact.  We would appreciate knowing about any errors or     *
  22. *    improvements.....                                                   *
  23. *                                                 Enjoy                  *
  24. *                                              John Youells              *
  25. *                                              QLink  "JAY"              *
  26. *                                              PLink OFR539              *
  27. *                                                                        *
  28. *    This program was compiled under ManxC and Lattice C v3.02.....      *
  29. *                                                                        *
  30. *    We would like to thank John Draper (aka Cap'n Crunch) for his       *
  31. *    excellent tutorial called "menus.c" which allowed us to build       *
  32. *    menu structures that are both smaller and more readable.            *
  33. *                                                                        *
  34. *    BUGS:  There is one - if you make the window smaller and then       *
  35. *    select an item the IntuiText is not clipped properly and will       *
  36. *    overwrite the window borders.  We understand that this bug in       *
  37. *    Workbench 1.1 ( and the manuals! ) will be corrected in 1.2.        *
  38. *                                                                        *
  39. *                                                                        *
  40. ************************************************************************ */
  41.  
  42. #include <exec/types.h>
  43. #include <exec/nodes.h>
  44. #include <exec/lists.h>
  45. #include <exec/ports.h>
  46. #include <exec/io.h>
  47. #include <exec/exec.h>
  48. #include <exec/execbase.h>
  49. #include <exec/devices.h>
  50. #include <exec/memory.h>
  51. #include <libraries/dos.h>
  52. #include <intuition/intuition.h>
  53. #include <devices/console.h>
  54. #include <devices/keymap.h>
  55. #include <graphics/regions.h>
  56. #include <graphics/copper.h>
  57. #include <graphics/gels.h>
  58. #include <graphics/gfxbase.h>
  59. #include <graphics/clip.h>
  60. #include <graphics/layers.h>
  61. #include <graphics/gfx.h>
  62. #include <graphics/view.h>
  63. #include <graphics/rastport.h>
  64. #include <hardware/blit.h>
  65.  
  66. /* Don't need all of these - just so tired of all those warnings */
  67.  
  68.  
  69.  
  70. /**************************************************************************
  71. *                      I M P O R T A N T   C O N S T A N T S              *
  72. **************************************************************************/
  73.  
  74.  
  75. #define  NL 0
  76.  
  77. /*** CLOSE FLAGS FOR VARIOUS THINGS ***/
  78.  
  79.  
  80. long mask = 0;
  81.  
  82. #define INTUITION 0x00000001
  83. #define GRAPHICS  0x00000002
  84. #define SCREEN    0x00000004
  85. #define WINDOW    0x00000008
  86. #define COLORMAP  0x00000010
  87. #define MENU      0x00000020
  88.  
  89. /***************************************************************************
  90. *                   F U N C T I O N   D E C L A R A T I O N S              *
  91. ***************************************************************************/
  92.  
  93.  
  94.  
  95. #define AZTEC               /* Comment this line out if using Lattice C */
  96.  
  97. #ifdef  AZTEC
  98.  
  99. extern void *OpenLibrary();
  100. extern struct Window *OpenWindow();
  101. extern struct IntuiMessage *GetMsg();
  102.  
  103. #endif
  104.  
  105. /**************************************************************************
  106.       THIS IS THE STRUCTURE DEFINITION FOR THE TEXT FILE FOR DOSHelper    *
  107. ***************************************************************************/
  108.  
  109. struct file
  110. {
  111. char line1[80];
  112. char line2[80];
  113. char line3[80];
  114. char line4[80];
  115. char line5[80];
  116. char line6[80];
  117. char line7[80];
  118. char line8[80];
  119. char line9[80];
  120. char line10[80];
  121. char line11[80];
  122. char line12[80];
  123. char line13[80];
  124. char line14[80];
  125. char line15[80];
  126. char line16[80];
  127. char line17[80];
  128. char line18[80];
  129. char line19[80];
  130. };
  131. #include <DHFiles>
  132.  
  133. /**************************************************************************
  134. *       I N T U I T I O N   G L O B A L   V A R I A B L E S               *
  135. **************************************************************************/
  136.  
  137.  
  138. struct IntuitionBase  *IntuitionBase;
  139. struct GfxBase        *GfxBase;
  140. struct IntuiMessage   *message;
  141. struct RastPort       *MyPort;
  142. struct Window         *w;
  143. struct IntuiText      display[23];   /*    display array                  */
  144. struct IntuiText      clear[23];     /*    clear the screen array         */
  145.  
  146.  
  147. /**************************************************************************
  148. *                 M E N U   D E F I N I T I O N S                         *
  149. **************************************************************************/
  150.  
  151.  
  152.  
  153. #define NUM_MENUS 4          /* number of menus */
  154.  
  155. /* Copies of this sturcture will get stamped into more structures        */
  156. /* allocated later                                                       */
  157.  
  158. struct IntuiText generic = {
  159.   0,1,                       /* background pen, foreground pen     */
  160.   JAM2,5,                    /* text mode, LeftEdge                */
  161.   0,NL,                      /* Top (to be filled in later), Front */
  162.   NL,                        /* Name (to be filled in later)       */ 
  163.   NL                         /* pointer to the next structure      */
  164.  
  165.                            };
  166.  
  167. /* Menu numbers */
  168.  
  169. #define SYSTEM_MENU        0
  170. #define BATCH_MENU         1
  171. #define FILE_MENU          2
  172. #define MISC_MENU          3
  173.  
  174. /* Menu widths */
  175.  
  176. #define SYSTEM_WIDTH  90
  177. #define BATCH_WIDTH   90
  178. #define FILE_WIDTH    90
  179. #define MISC_WIDTH    90
  180.  
  181.  
  182. /* initialize an array of item withs */
  183.  
  184. int item_widths[ NUM_MENUS ] ={   95,95,95,95   };
  185.  
  186. /* all menu items have the following flags set */
  187.  
  188. #define BOX_FILL  ITEMTEXT | ITEMENABLED | HIGHBOX
  189.  
  190. /************************* MISC MENU *****************/
  191.  
  192. #define NUM_MISC     4   /* number of items in menu */
  193. #define Say          0   /* an item number for each */
  194. #define Why          1
  195. #define Help         2
  196. #define About        3
  197. struct MenuItem misc_items[ NUM_MISC ];
  198. struct IntuiText  misc_names[ NUM_MISC ];
  199.  
  200. char *misces_names[]={
  201.    "Say",                   /* text for the item names  */
  202.    "Why",
  203.    "HELP",
  204.    "ABOUT...",
  205.                      };
  206.  
  207. struct Menu misc_menu={
  208.    NL,                                            /* no next menu */
  209.    20 + SYSTEM_WIDTH + BATCH_WIDTH + FILE_WIDTH,  /* LeftEdge */
  210.    0, MISC_WIDTH, 10 ,                         /* TopEdge, Width, Height */
  211.    MENUENABLED,                                   /* FLAGS */
  212.    "Misc.",                                       /* name of menu */
  213.    misc_items                                     /* first item structure */
  214.                       } ;
  215.  
  216. /* Repeat this for each menu */
  217.  
  218.  
  219. /******************** FILE MENU ***************/
  220.  
  221. #define NUM_FILE  13
  222. #define Copy      0
  223. #define Delete    1
  224. #define Dir       2
  225. #define Ed        3
  226. #define Edit      4
  227. #define Filenote  5
  228. #define Join      6
  229. #define Protect   7
  230. #define Relabel   8
  231. #define Rename    9
  232. #define Search    10
  233. #define Sort      11
  234. #define Type      12
  235.  
  236. struct MenuItem file_items[ NUM_FILE ];
  237. struct IntuiText file_names[ NUM_FILE ];
  238.  
  239. char *files_names[]={
  240.  
  241.             "Copy",
  242.             "Delete",
  243.             "Dir",
  244.             "Ed",
  245.             "Edit",
  246.             "Filenote",
  247.             "Join",
  248.             "Protect",
  249.             "Relabel",
  250.             "Rename",
  251.             "Search",
  252.             "Sort",
  253.             "Type"
  254.                     };
  255.  
  256. struct Menu file_menu={
  257.    &misc_menu,
  258.    20 + BATCH_WIDTH + SYSTEM_WIDTH,
  259.    0,  FILE_WIDTH, 10,
  260.    MENUENABLED,
  261.    "File",
  262.    file_items
  263.                        };
  264.  
  265.  
  266. /******************** BATCH MENU *********************/
  267.  
  268. #define NUM_BATCH 9
  269. #define Echo      0
  270. #define Execute   1
  271. #define Failat    2
  272. #define Fault     3
  273. #define If        4
  274. #define Lab       5
  275. #define Quit      6
  276. #define Skip      7
  277. #define wait      8
  278.  
  279. struct MenuItem batch_items[ NUM_BATCH ];
  280. struct IntuiText batch_names[ NUM_BATCH ];
  281.  
  282. char *batches_names[]={
  283.             "Echo",
  284.             "Execute",
  285.             "Failat",
  286.             "Fault",
  287.             "If",
  288.             "Lab",
  289.             "Quit",
  290.             "Skip",
  291.             "Wait"
  292.                       };
  293.  
  294. struct Menu batch_menu={
  295.    &file_menu,
  296.    20 + SYSTEM_WIDTH,
  297.    0,  BATCH_WIDTH,   10,
  298.    MENUENABLED,
  299.    "Batch",
  300.    batch_items
  301.                        };
  302.  
  303.  
  304. /*********************************** SYSTEM MENU ************/
  305.  
  306. #define NUM_SYSTEM  16
  307. #define Assign       0
  308. #define Break        1
  309. #define Cd           2
  310. #define Date         3
  311. #define Diskcopy     4
  312. #define Endcli       5
  313. #define Format       6
  314. #define Info         7
  315. #define Install      8
  316. #define List         9
  317. #define Makedir     10
  318. #define Newcli      11
  319. #define Prompt      12
  320. #define Run         13
  321. #define Stack       14
  322. #define Status      15
  323.  
  324. struct MenuItem system_items[ NUM_SYSTEM ];
  325. struct IntuiText system_names[ NUM_SYSTEM ];
  326.  
  327. char *systems_names[]={
  328.             "Assign",
  329.             "Break",
  330.             "Cd",
  331.             "Date",
  332.             "Diskcopy",
  333.             "Endcli",
  334.             "Format",
  335.             "Info",
  336.             "Install",
  337.             "List",
  338.             "Makedir",
  339.             "Newcli",
  340.             "Prompt",
  341.             "Run",
  342.             "Stack",
  343.             "Status"
  344.                       };
  345.  
  346.  
  347. struct Menu system_menu={
  348.    &batch_menu,
  349.    20,
  350.    0,  SYSTEM_WIDTH, 10,
  351.    MENUENABLED,"System",
  352.    system_items
  353.  
  354.                          };
  355.                              /* Thats all for the menus - whew!       */
  356.                              /* But its a lot longer to do the        */
  357.                              /* way its shown in the Intuition Manual */  
  358.                              /*   Thanks John!                        */
  359.  
  360. /***************************************************************************
  361. *                N E W   W I N D O W   S T R U C T U R E                   *
  362. ***************************************************************************/
  363.  
  364.  
  365. struct  NewWindow  nw = {
  366.    0, 0,                     /*   Start Position                      */
  367.    640, 200,                 /*   Width, Height,                      */
  368.    0, 1,                     /*   DetailPen, BlockPen                 */
  369.      CLOSEWINDOW             /*   IDCMPFlags                          */
  370.    | REFRESHWINDOW
  371.    | MOUSEBUTTONS
  372.    | MENUPICK ,
  373.      WINDOWDEPTH             /* Regular flags for gadgets attached to */
  374.    | WINDOWSIZING            /* the window and its characteristics    */
  375.    | WINDOWDRAG
  376.    | WINDOWCLOSE
  377.    | SMART_REFRESH           /* For the window title below we cast    */
  378.    | ACTIVATE ,              /* the pointer to an unsigned char to    */
  379.                              /* avoid compiler warnings...            */
  380.  
  381.      NULL,                   /* no user defined Gadgets               */
  382.      NULL,                   /* no user defined CheckMark             */
  383.  
  384.      (UBYTE *)"   DOSHelper  ⌐  1986 LifeStream  Version 1.60   15Aug86 ",
  385.  
  386.      NULL,                   /* pointer to Screen (set if custom )    */
  387.      NULL,                   /* pointer to SUPER_BITMAP               */
  388.      60, 80, 640, 200,       /* MinWidth, MinHeight, MaxWidth,        */
  389.                              /* MaxHeight for resizing                */
  390.      WBENCHSCREEN,           /* Use the standard screen type          */
  391.                         };
  392.  
  393. /*************************************************************************
  394. *            P R I N T  to the  S C R E E N                              *
  395. **************************************************************************/
  396.  
  397.  
  398. print(port,file)
  399. struct RastPort *port;
  400. int file;
  401. {
  402.     PrintIText(port,&clear,10,11);
  403.     display[1].IText=(UBYTE *)files[file].line1;
  404.     display[2].IText=(UBYTE *)files[file].line2;
  405.     display[3].IText=(UBYTE *)files[file].line3;
  406.     display[4].IText=(UBYTE *)files[file].line4;
  407.     display[5].IText=(UBYTE *)files[file].line5;
  408.     display[6].IText=(UBYTE *)files[file].line6;
  409.     display[7].IText=(UBYTE *)files[file].line7;
  410.     display[8].IText=(UBYTE *)files[file].line8;
  411.     display[9].IText=(UBYTE *)files[file].line9;
  412.     display[10].IText=(UBYTE *)files[file].line10;
  413.     display[11].IText=(UBYTE *)files[file].line11;
  414.     display[12].IText=(UBYTE *)files[file].line12;
  415.     display[13].IText=(UBYTE *)files[file].line13;
  416.     display[14].IText=(UBYTE *)files[file].line14;
  417.     display[15].IText=(UBYTE *)files[file].line15;
  418.     display[16].IText=(UBYTE *)files[file].line16;
  419.     display[17].IText=(UBYTE *)files[file].line17;
  420.     display[18].IText=(UBYTE *)files[file].line18;
  421.     display[19].IText=(UBYTE *)files[file].line19;
  422.     PrintIText(port,&display,10,11);
  423. }
  424.  
  425. /**************************************************************************
  426. *                C L E A R   the   S C R E E N                            * 
  427. ***************************************************************************/
  428.  
  429. /*  There is a built in function to do this but so far either we or the
  430.   compilers can't get it right.  So we will build our own....             */
  431.  
  432.  
  433.  
  434. Setclear()
  435. {
  436.  
  437.  
  438. int i;
  439. int y;
  440. for(i=0;i<21;i++)
  441.   {
  442. clear[i].FrontPen=1;
  443. clear[i].BackPen=0;
  444. clear[i].DrawMode=JAM2;
  445. clear[i].LeftEdge=2;
  446. clear[i].TopEdge=i*9;
  447. clear[i].ITextFont=NULL;
  448. clear[i].IText=(UBYTE *)"                                                                            ";
  449.   }
  450. for(y=0;y<21;y++)
  451.   {
  452. clear[y].NextText=&clear[y+1];
  453.   }
  454. clear[21].NextText=NULL;
  455. }
  456.  
  457. /*************************************************************************/
  458.  
  459. SetUpDisplay()
  460. {
  461.  
  462. int i;
  463. int y;
  464. for(i=0;i<21;i++)
  465.   {
  466. display[i].FrontPen=1;
  467. display[i].BackPen=0;
  468. display[i].DrawMode=JAM2;
  469. display[i].LeftEdge=2;
  470. display[i].TopEdge=i*9;
  471. display[i].ITextFont=NULL;
  472.    }
  473. for(y=0;y<20;y++)
  474.    {
  475. display[y].NextText=&display[y+1];
  476.    }
  477. display[20].NextText=NULL;
  478. }
  479. /***************************************************************************
  480. *             M A I N   P R O G R A M   M O D U L E                        *
  481. ***************************************************************************/
  482.  
  483.      
  484.  
  485.  
  486.  
  487. main()
  488. {
  489. ULONG class;
  490. USHORT code;
  491. int    i;
  492.  
  493.  
  494. /************************************************************************
  495. *  Read in libraries, and set each "read" mask bit                      *
  496. ************************************************************************/
  497.  
  498.  
  499.    if(!(GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",0L)))
  500.    {
  501.       puts("no graphics library!!!");
  502.       close_things();
  503.       exit(1);
  504.    }
  505.    mask |= GRAPHICS;
  506.  
  507.  if(!(IntuitionBase = (struct IntuitionBase *)
  508.        OpenLibrary("intuition.library",0L)))
  509.    {
  510.       puts("no intuition here!!");
  511.       close_things();
  512.       exit(2);
  513.    }
  514.    mask |= INTUITION;
  515.  
  516. /***************************************************************************
  517.                 OPEN UP THE WINDOW ON TOP OF WORKBENCH SCREEN
  518. ***************************************************************************/
  519.  
  520.    if (!(w = (struct Window *)OpenWindow(&nw) ))
  521.    {
  522.       puts("could not open the window");
  523.       close_things();
  524.       exit(3);
  525.    }
  526.    mask |= WINDOW;
  527.  
  528. /***************************************************************************
  529.                           CREATE THE THREE MENUS
  530. ***************************************************************************/
  531.  
  532.  
  533. NewMenu(&system_menu,systems_names,system_items,system_names,NUM_SYSTEM,
  534.         item_widths[0],BOX_FILL);
  535.  
  536. NewMenu(&batch_menu,batches_names,batch_items,batch_names,NUM_BATCH,
  537.         item_widths[1],BOX_FILL);
  538.  
  539. NewMenu(&file_menu,files_names,file_items,file_names,NUM_FILE,
  540.         item_widths[2],BOX_FILL);
  541.  
  542. NewMenu(&misc_menu,misces_names,misc_items,misc_names,NUM_MISC,
  543.         item_widths[3],BOX_FILL);
  544.  
  545.  
  546. MyPort=w->RPort;
  547.  
  548. SetMenuStrip( w,&system_menu);
  549. Setclear();
  550. SetUpDisplay();
  551.  
  552. for (;;)
  553.  
  554.  
  555.   {
  556.  
  557.    if ((message = (struct IntuiMessage *) GetMsg(w->UserPort)) == 0L)  {
  558.    Wait(1L<<w->UserPort->mp_SigBit);
  559.    continue;
  560.                                                                         }
  561.  
  562.    class=message->Class;
  563.    code=message->Code;
  564.    ReplyMsg(message);
  565.    switch (class)  {
  566.  
  567.  
  568.            case CLOSEWINDOW : close_things();
  569.                               exit(0);
  570.                               break;
  571.  
  572.            case MENUPICK    : if (MENUNUM(code) != MENUNULL)
  573.                                 domenu(MENUNUM(code), ITEMNUM(code),
  574.                                        SUBNUM(code));
  575.                               break;
  576.           case MOUSEBUTTONS : break;
  577.                     }   /* Case */
  578.   }  /* for */
  579. }   /* End of Main */
  580.  
  581. /***************************************************************************
  582.                         DO THE MENU SELECTIONS
  583. ***************************************************************************/
  584. domenu(menu, item, subitem)
  585. int  menu, item, subitem;
  586. {
  587.    switch (menu)  {
  588.  
  589.          case SYSTEM_MENU:
  590.                switch(item)
  591.                     {
  592.                      case Assign:
  593.                            print(MyPort,0);
  594.                            break;
  595.                      case Break:
  596.                            print(MyPort,1);
  597.                            break;
  598.                      case Cd:
  599.                            print(MyPort,2);
  600.                            break;
  601.                      case Date:
  602.                            print(MyPort,4);
  603.                            break;
  604.                      case Diskcopy:
  605.                            print(MyPort,7);
  606.                            break;
  607.                      case Endcli:
  608.                            print(MyPort,11);
  609.                            break;
  610.                      case Format:
  611.                            print(MyPort,16);
  612.                            break;
  613.                      case Info:
  614.                            print(MyPort,18);
  615.                            break;
  616.                      case Install:
  617.                            print(MyPort,19);
  618.                            break;
  619.                      case List:
  620.                            print(MyPort,22);
  621.                            break;
  622.                      case Makedir:
  623.                            print(MyPort,23);
  624.                            break;
  625.                      case Newcli:
  626.                            print(MyPort,24);
  627.                            break;
  628.                      case Prompt:
  629.                            print(MyPort,25);
  630.                            break;
  631.                      case Run:
  632.                            print(MyPort,30);
  633.                            break;
  634.                      case Stack:
  635.                            print(MyPort,34);
  636.                            break;
  637.                      case Status:
  638.                            print(MyPort,35);
  639.                            break;
  640.                     }
  641.             break;
  642.             case BATCH_MENU:
  643.                switch(item)
  644.                     {
  645.  
  646.                      case Echo:
  647.                            print(MyPort,8);
  648.                            break;
  649.                      case Execute:
  650.                            print(MyPort,12);
  651.                            break;
  652.                      case Failat:
  653.                            print(MyPort,13);
  654.                            break;
  655.                      case Fault:
  656.                            print(MyPort,14);
  657.                            break;
  658.                      case If:
  659.                            print(MyPort,17);
  660.                            break;
  661.                      case Lab:
  662.                            print(MyPort,21);
  663.                            break;
  664.                      case Quit:
  665.                            print(MyPort,27);
  666.                            break;
  667.                      case Skip:
  668.                            print(MyPort,32);
  669.                            break;
  670.                      case wait:
  671.                            print(MyPort,37);
  672.                            break;
  673.                      }
  674.             break;
  675.            case FILE_MENU:
  676.                 switch(item)
  677.                      {
  678.  
  679.  
  680.                      case Copy:
  681.                            print(MyPort,3);
  682.                            break;
  683.                      case Delete:
  684.                            print(MyPort,5);
  685.                            break;
  686.                      case Dir:
  687.                            print(MyPort,6);
  688.                            break;
  689.                      case Ed:
  690.                            print(MyPort,9);
  691.                            break;
  692.                      case Edit:
  693.                            print(MyPort,10);
  694.                            break;
  695.                      case Filenote:
  696.                            print(MyPort,15);
  697.                            break;
  698.                      case Join:
  699.                            print(MyPort,20);
  700.                            break;
  701.                      case Protect:
  702.                            print(MyPort,26);
  703.                            break;
  704.                      case Relabel:
  705.                            print(MyPort,28);
  706.                            break;
  707.                      case Rename:
  708.                            print(MyPort,29);
  709.                            break;
  710.                      case Search:
  711.                            print(MyPort,31);
  712.                            break;
  713.                      case Sort:
  714.                            print(MyPort,33);
  715.                            break;
  716.                      case Type:
  717.                            print(MyPort,36);
  718.                            break;
  719.                      }
  720.               break;
  721.               case MISC_MENU:
  722.                 switch(item)
  723.                      {
  724.  
  725.                      case Say:
  726.                            print(MyPort,39);
  727.                            break;
  728.                      case Why:
  729.                            print(MyPort,38);
  730.                            break;
  731.                      case Help:
  732.                            print(MyPort,40);
  733.                            break;
  734.                      case About:
  735.                            print(MyPort,41);
  736.                            break;
  737.  
  738.                      }
  739.               break;
  740.  
  741.  
  742.                    }
  743.  }
  744.  
  745.  
  746. /**************************************************************************
  747. *              C R E A T E   A   N E W   M E N U                          *
  748. **************************************************************************/
  749.  
  750.  
  751. NewMenu(menu, item_names, menu_items, menu_text, num_items, Mwidth, flag)
  752.  
  753. struct Menu       *menu;
  754. unsigned char     *item_names[];
  755. struct MenuItem   menu_items[];
  756. struct IntuiText  menu_text[];
  757. int               num_items;
  758. int               Mwidth;
  759. int               flag;
  760. {
  761.    int i;
  762.    int height=0;
  763.    for (i=0; i< num_items; i++)
  764.      {
  765.  
  766.    menu_text[i]= generic;
  767.    menu_text[i].IText=item_names[i];
  768.    menu_items[i].NextItem = &menu_items[i + 1];
  769.    menu_items[i].TopEdge= 10 * i;
  770.    menu_items[i].LeftEdge=0;
  771.    menu_items[i].Height=8;
  772.    menu_items[i].ItemFill=(APTR)&menu_text[i];
  773.    menu_items[i].Flags=flag;
  774.    menu_items[i].Width=Mwidth;
  775.    menu_items[i].MutualExclude = 0x0000;
  776.    menu_items[i].Command =0;
  777.    menu_items[i].SubItem=NL;
  778.    menu_items[i].NextSelect=NL;
  779.    height += 10;
  780.      }
  781.  
  782.    menu_items[num_items-1].NextItem=NULL;
  783.    menu->Height=height;
  784. }
  785.  
  786.  
  787.  
  788. /***************************************************************************
  789.                      C L O S E      T H I N G S
  790. ***************************************************************************/
  791.  
  792. close_things()
  793. {
  794.    if (mask & MENU)      ClearMenuStrip(w, &system_menu);
  795.    if (mask & WINDOW)    CloseWindow(w);
  796.    if (mask & GRAPHICS)  CloseLibrary(GfxBase);
  797.       OpenWorkBench();
  798.    if (mask & INTUITION) CloseLibrary(IntuitionBase);
  799. }
  800.  
  801.